package _base0to1;

/**
 * 1768. 交替合并字符串
 */
public class No1768 {
    public String mergeAlternately(String word1, String word2) {
        int n = word1.length();
        int m = word2.length();
        char[] answer = new char[n + m];
        int i = 0;
        for (; i < Math.min(n, m); i++) {
            answer[2 * i] = word1.charAt(i);
            answer[2 * i + 1] = word2.charAt(i);
        }

        for (int j = i; j < Math.max(n, m); j++) {
            answer[i + j] = n > m ? word1.charAt(j) : word2.charAt(j);
        }
        return new String(answer);
    }
}
